package com.mofang.adapters;

import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.mofang.R;
import com.mofang.activity.user.AreaSelectActivity.Area;

public class AreaSelectAdapter extends BaseAdapter {

	private LayoutInflater mInflater;
	private List<Area> data;
	Context context;
	int count = 10;

	public AreaSelectAdapter(Context context, List<Area> data) {
		this.mInflater = LayoutInflater.from(context);
		this.context = context;
		this.data = data;
	}

	
	
	public void setData(List<Area> data) {
		this.data = data;
	}



	@Override
	public int getCount() {
		return data.size();
	}

	@Override
	public Object getItem(int position) {
		return position;
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		Holder myHolder;
		if (convertView == null) {
			myHolder = new Holder();
			convertView = mInflater.inflate(R.layout.area_select_list_item,
					null);
			myHolder.name = (TextView) convertView
					.findViewById(R.id.txt_area_name);
			convertView.setTag(myHolder);
		} else {
			myHolder = (Holder) convertView.getTag();
		}
		myHolder.name.setText(data.get(position).name);
		return convertView;
	}

	class Holder {
		TextView name;
	}

}
